home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / LSGETCUR.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  85 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)lsgetcur.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10. #ifdef AC_STRING
  11. #include <string.h>
  12. #endif
  13.  
  14. /* library headers */
  15. #include <blkio.h>
  16.  
  17. /* local headers */
  18. #include "lseq_.h"
  19.  
  20. /*man---------------------------------------------------------------------------
  21. NAME
  22.      lsgetcur - get lseq cursor
  23.  
  24. SYNOPSIS
  25.      #include <lseq.h>
  26.  
  27.      int lsgetcur(lsp, lsposp)
  28.      lseq_t *lsp;
  29.      lspos_t *lsposp;
  30.  
  31. DESCRIPTION
  32.      The lsgetcur function gets the current cursor position of lseq
  33.      lsp and copies it to the location pointed to by lsposp.  A lseq
  34.      position saved with lsgetcur can be used to reposition to a
  35.      record using lssetcur.  It is important to remember that an lseq
  36.      position saved with lsgetcur is not valid after that lseq has
  37.      been unlocked.
  38.  
  39.      lsgetcur will fail if one or more of the following is true:
  40.  
  41.      [EINVAL]       lsp is not a valid lseq pointer.
  42.      [EINVAL]       lsposp is the NULL pointer.
  43.      [LSELOCK]      lsp is not locked.
  44.      [LSENOPEN]     lsp is not open.
  45.  
  46. SEE ALSO
  47.      lssetcur.
  48.  
  49. DIAGNOSTICS
  50.      Upon successful completion, a value of 0 is returned.  Otherwise,
  51.      a value of -1 is returned, and errno set to indicate the error.
  52.  
  53. ------------------------------------------------------------------------------*/
  54. #ifdef AC_PROTO
  55. int lsgetcur(lseq_t *lsp, lspos_t *lsposp)
  56. #else
  57. int lsgetcur(lsp, lsposp)
  58. lseq_t *lsp;
  59. lspos_t *lsposp;
  60. #endif
  61. {
  62.     /* validate arguments */
  63.     if (!ls_valid(lsp) || lsposp == NULL) {
  64.         errno = EINVAL;
  65.         return -1;
  66.     }
  67.  
  68.     /* check if not open */
  69.     if (!(lsp->flags & LSOPEN)) {
  70.         errno = EINVAL;
  71.         return -1;
  72.     }
  73.  
  74.     /* check if not read locked */
  75.     if (!(lsp->flags & LSLOCKS)) {
  76.         errno = LSELOCK;
  77.         return -1;
  78.     }
  79.  
  80.     /* get current position */
  81.     memcpy(lsposp, &lsp->clspos, sizeof(lsp->clspos));
  82.  
  83.     return 0;
  84. }
  85.